package org.example.product.service.impl;

import org.example.product.entity.ResultBody;
import org.example.product.mapper.RelProMapper;
import org.example.product.service.RelProService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class RelProServiceimpl implements RelProService {
    @Autowired
    private RelProMapper relProMapper;
    @Override
    public int addProduct(String code,String category,String name,String description,Double price,String phone,String avatar_Url)
    {

        if(relProMapper.addGoods(code,category,name,description,price,phone,avatar_Url)>0)
        {
            return 1;
        }
        return 0;
    }
    @Override
    public ResultBody displayProduct(String phone)
    {
        if(!relProMapper.displayProduct(phone).isEmpty())
            return new ResultBody(200,"查询成功",relProMapper.displayProduct(phone),relProMapper.displayProduct(phone).size()) ;
        else
            return new ResultBody(400,"查询失败",false);
    }
    @Override
    public ResultBody getAllMessage()
    {
        if(!relProMapper.getAllMessage().isEmpty())
        {
            return new ResultBody(200,"展示已上架商品成功",relProMapper.getAllMessage(),relProMapper.getAllMessage().size());
        }
        else
            return new ResultBody(400,"展示上架商品失败",false);

    }
    @Override
    public ResultBody displayShopR()
    {
        if(!relProMapper.displayShopR().isEmpty())
        {
            return new ResultBody(200,"展示已上架商品成功",relProMapper.displayShopR(),relProMapper.displayShopR().size());
        }
        else
            return new ResultBody(400,"展示上架商品失败",false);
    }
    @Override
    public ResultBody decision(String decision,String code)
    {
        if(relProMapper.decision(decision,code)!=null)
        {
            return new ResultBody(200,"操作成功",true);
        }
        else
            return new ResultBody(400,"操作失败",false);
    }


}
